<template>
	<view>
		<zx-head Title="测评记录" :isShowR="false"></zx-head>
		<view class="list">
			<view class="time">
				2024年08月01日
			</view>
			<view v-for="(item,index) in pageList">
				<view class="item _df _ac _jb" v-for="(dom,index) in item.treeRelationJson.children" :key="index"
					@click="toResult(item)">
					<view class="text">
						<view class="title clamp1">
							{{dom.name}}
						</view>
						<view class="info clamp1">
							{{item.singleSetJson.experimentName}}
						</view>
					</view>
					<view class="num">
						<!-- 抑郁概率 4.8% -->{{dom.updateTime}}
						<u-icon class="ml20" name="arrow-right" color="#888" size="28"></u-icon>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: {
					orderParam: [{
						asc: false,
						dateAggregateBy: "",
						fieldName: "createTime"
					}],
					pageParam: {
						pageNum: 1,
						pageSize: 10
					},
					participantExperimentRecordDtoFilter: {
						participantInfoId: "1844273178176655360"
					}
				},

				pageList: [{
					treeRelationJson: [{
						children: []
					}],
					singleSetJson: {}
				}],
				totalPage: 1,
				token: ""

			};
		},
		onLoad() {

			this.getZxUserId();
			this.getPageList();
		},
		onShow() {

		},
		methods: {
			toResult(e) {
				uni.navigateTo({
					url: '/pages/comA/zhixin/detail'
				})
			},
			getPageList() {
				let thisData = this;
				if (thisData.page.participantExperimentRecordDtoFilter.participantInfoId == null || thisData.page
					.participantExperimentRecordDtoFilter.participantInfoId.length == 0) {
					uni.showToast({
						title: "请前往个人中心完善个人信息！",
						duration: 1500,
						icon: 'error'
					});
					return;
				}
				let data = {
					"url": "/admin/app/participantExperimentRecord/list",
					"data": thisData.page
				}
				uni.$_post({
					url: "getRequestResult",
					that: thisData,
					params: data,
					success(res) {
						let _data = res.data.data.dataList;
						if (res.data.success) {
							for (var i = 0; i < _data.length; i++) {
								_data[i].singleSetJson = JSON.parse(_data[i].singleSetJson)
								_data[i].treeRelationJson = JSON.parse(_data[i].treeRelationJson)
							}

							console.log(_data);
							//分页
							if (_data.length == 0) {
								thisData.totalPage = 0;
							}
							if (thisData.page.pageParam.pageNum > 1) {
								thisData.pageList = thisData.pageList.concat(_data);
							} else {
								thisData.pageList = _data;
							}
							this.$refs.more.status = "loadmore";
						} else {
							uni.showToast({
								title: res.msg,
								duration: 1500,
								icon: 'error'
							});
						}
					},
					fail(err) {
						uni.showToast({
							title: err.msg,
							duration: 1000,
							icon: 'error'
						});
					},
				});
			},
			getZxUserId() {
				let thisData = this;
				uni.$_get({
					url: "getZxUserId",
					that: thisData,
					success(res) {
						if (res.code == 0) {
							thisData.page.participantExperimentRecordDtoFilter.participantInfoId = res.data;
						} else {
							uni.showToast({
								title: "知心异常！",
								duration: 1500,
								icon: 'error'
							});
						}
					}
				});
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f5f5;
	}

	.list {
		padding: 30rpx;

		.time {
			font-size: 26rpx;
			color: #888;
			margin-bottom: 30rpx;
		}

		.item {
			background: #ffffff;
			border-radius: 20rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.05);
			margin-bottom: 30rpx;
			padding: 35rpx 30rpx;
			box-sizing: border-box;

			.title {
				font-size: 30rpx;
				color: #000000;
				font-family: $uni-font-family-Heavy;
				margin-bottom: 10rpx;
			}

			.info {
				font-size: 22rpx;
				color: #999;
			}

			.num {
				font-size: 24rpx;
				color: #666;

			}
		}
	}
</style>